package com.hqq.other.lazy_loading;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Thread Safe Holder
 * Created by heqianqian on 2017/9/4.
 */
public class HolderThreadSafe {

    private static final Logger LOGGER = LoggerFactory.getLogger(HolderThreadSafe.class);

    private Heavy heavy;

    public HolderThreadSafe() {
        LOGGER.info("HolderThreadSafe created");
    }

    public synchronized Heavy getHeavy() {
        if (heavy == null) {
            heavy = new Heavy();
        }
        return heavy;
    }

}
